package com.shi.yibanjia.config;

import com.shi.yibanjia.interceptor.AuthCheckInterceptor;
import com.shi.yibanjia.interceptor.RefreshTokenInterceptor;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

import javax.annotation.Resource;

@Configuration
public class WebMvcConfig implements WebMvcConfigurer {

    @Resource
    private AuthCheckInterceptor authCheckInterceptor;

    @Resource
    private RefreshTokenInterceptor refreshTokenInterceptor;

    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        registry.addInterceptor(authCheckInterceptor)
                .excludePathPatterns("/app/index/login", "/app/common/**", "/app/carType", "/app/carryAndTransport", "/app/publicity","/test/**","/app/index/logout")
                .order(1);
        registry.addInterceptor(refreshTokenInterceptor)
                .addPathPatterns("/**")
                .order(2);
    }

}
